//  Copyright (C) 2014 Xiande (Triston) Cao

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef CVSIE_EDGE_H
#define CVSIE_EDGE_H

#include "cvsie_meshnode.hpp"

namespace cvsie {

  class CEdge {
      // A edge is defined by two mesh nodes and it is identified by its 
      // id number
    private:
      int id;
      CMeshNode *first_node;
      CMeshNode *second_node;
      double length;
    private:
      inline void UpdateLength(); 

    public:
      inline int GetId() const;
      inline void SetId(int _id);

      inline CMeshNode * GetFistNode() const;
      inline void SetFistNode(CMeshNode *node); 

      inline CMeshNode * GetSecondNode() const;
      inline void SetSecondNode(CMeshNode *node);

      inline void SetFirstAndSecondNode(CMeshNode * _first_node,
          CMeshNode * _second_node);

      double GetLength() const;
      //No SetLength(), length are automatically updated;

    public:
      // ctors
      CEdge(int _id = -1, CMeshNode * _first_node = NULL, 
          CMeshNode * _second_node = NULL, double _length = 0); 
      CEdge &operator=(const CEdge &src);

    public:
      // for sortings purpose
      inline bool operator==(const CEdge &rhs) const;
      inline bool operator<(const CEdge &rhs) const;
  };

} // namespace cvsie
#endif // CVSIE_EDGE_H
